package org.zanpu.metadataserver.core.aop;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import org.zanpu.metadataserver.core.dbmanager.DynamicDataSource;

/**
 * Created by MD on 2016/10/26.
 */
@Aspect
@Component
@Order(1)
public class DataSourceAspect {



    @Before("@annotation(org.zanpu.metadataserver.core.aop.ServiceDataSource) && @annotation(sd)")
    public void dataSource(JoinPoint jp, ServiceDataSource sd){

        DynamicDataSource.setCurrentLookupKey(sd.value());
    }
}
